package com.baturu.vin.benz.dal.dao;

import com.baturu.vin.benz.dto.BenzEPCPartsInfoForQueryDTO;
import com.baturu.vin.benz.dto.BenzFootnoteDTO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * @author jiangxinlei
 * @Time 2017/4/18.
 */
public interface BenzFootnoteDAO {

    @Select({"<script>select a.catNum,a.groupNum, a.ftntNum, a.revVer, a.listNum,a.HAS_WISLINK as hasWisLink, b.descIdx, b.abbr, b.lang, b.text, b.seqNum, a.kb,b.CONTINUED",
            "from BM_FOOTNOTES_V2 as a, BM_FOOTNOTES_DICTIONARY_V as b",
            "where (a.catnum, a.groupnum) in ",
            "<foreach item='item' index='index' collection='partsInfos' open='(' separator=',' close=')'>",
            "(#{item.catNum}, #{item.groupNum})",
            "</foreach>",
            "AND a.DESCIDX = b.DESCIDX",
            "AND b.LANG IN ('Z','N','E')",

            "</script>"})
    List<BenzFootnoteDTO> findFootnotesByParts(@Param("partsInfos") List<BenzEPCPartsInfoForQueryDTO> partsInfoForQueryDTOS);

    @Select({"select whc, plants from benz_whc_master_v"})
    List<Map<String, String>> getPlantsCodes();

    /**
     * 通过车型和组号查询脚注信息
     *
     * @param carNo
     * @param groupNo
     * @param landCode
     * @return
     */
    @Select({"<script>select a.catNum,a.groupNum, a.ftntNum, a.revVer, a.listNum,a.HAS_WISLINK as hasWisLink, b.descIdx, b.abbr, b.lang, b.text, b.seqNum, a.kb,b.CONTINUED",
            "from BM_FOOTNOTES_V2 as a, BM_FOOTNOTES_DICTIONARY_V as b",
            "where a.catnum=#{catNum} and  a.groupnum=#{groupNo} ",
            "AND a.DESCIDX = b.DESCIDX",
            "AND b.LANG IN (#{landCode},'N','E')",
            "</script>"})
    List<BenzFootnoteDTO> queryFootNoteByCarInfo(@Param("catNum") String carNo, @Param("groupNo") String groupNo, @Param("landCode") String landCode);

}
